//
//  MyNotificationContentViewController.m
//  xpkc
//
//  Created by TopSageOSX on 14-8-22.
//  Copyright (c) 2014年 wanmeizty. All rights reserved.
//

#import "MyNotificationContentViewController.h"

@interface MyNotificationContentViewController ()

@end

@implementation MyNotificationContentViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.navigationItem.title = @"通知内容";
//        [self.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
//                                                 [UIColor colorWithRed:255/255.0f green:159/255.f blue:0/255.f alpha:1], NSForegroundColorAttributeName,
//                                                 nil] forState:UIControlStateSelected];
    }
    return self;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
//    [self creatNavItem];
    [self creatView];
    NSLog(@"=======================%@=+===============",self.dic);
}
/**
 *  创建导航
 */
//-(void)creatNavItem{
//    UIImage *image = [UIImage imageNamed:@"backimg"];
//    if (IsIOS7) {
//        image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    }
//    UIBarButtonItem *backItem = [[UIBarButtonItem alloc]initWithImage:image style:UIBarButtonItemStyleBordered target:self action:@selector(backtonotification)];
//    self.navigationItem.leftBarButtonItem = backItem;
//}
//-(void)backtonotification{
//    [self.navigationController popViewControllerAnimated:YES];
//}
-(void)creatView{
//    logdebug(@"%@",self.dic);
    if (IsIOS7) {
        [self setEdgesForExtendedLayout:UIRectEdgeNone];
    }
    self.notiView = [[MyNotificationView alloc]initWithFrame:self.view.bounds];
    self.notiView.title.text = [self.dic objectForKey:@"title"];
    self.notiView.time.text = [self.dic objectForKey:@"timeStr"];
    self.notiView.webView.delegate =  self;
//    logdebug(@"%@",[self.dic objectForKey:@"content"]);
    [self.notiView.webView loadHTMLString:[self.dic objectForKey:@"content"] baseURL:[NSURL URLWithString:@""]];
    [self.view addSubview:self.notiView];
}
#pragma mark - webviewdelegate
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    //使用浏览器打开连接
    NSURL *requestURL =[ request URL  ];
    if ( ( [ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ] || [ [ requestURL scheme ] isEqualToString: @"mailto" ])
        && ( navigationType == UIWebViewNavigationTypeLinkClicked ) ) {
        return ![ [ UIApplication sharedApplication ] openURL:requestURL];
    }
    return YES;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
